package com.huawei.hwid.core.b.a.a;

import android.content.Context;
import android.os.Bundle;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.huawei.hwid.core.b.a.a;
import com.huawei.hwid.core.d.b;
import com.huawei.hwid.core.d.p;
import com.huawei.hwid.core.datatype.UserInfo;
import com.huawei.hwid.f.g;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;

public class e extends a {
    Context h;
    private String i;
    private String j;
    private String k;
    private String l;
    private String m = "/IUserInfoMng/serviceLogout";

    public e(Context context, String str, String str2, String str3) {
        this.h = context;
        this.i = str;
        this.j = str2;
        this.k = str3;
    }

    public String j() throws IllegalArgumentException, IllegalStateException, IOException {
        OutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        XmlSerializer a = p.a(byteArrayOutputStream);
        a.startDocument("UTF-8", Boolean.valueOf(true));
        a.startTag(null, "ServiceLogoutReq");
        p.a(a, "version", "27120");
        p.a(a, "userID", this.i);
        p.a(a, "appID", this.j);
        p.a(a, "tokenOrST", this.k);
        p.a(a, UserInfo.LANGUAGECODE, c(this.h));
        a.endTag(null, "ServiceLogoutReq");
        a.endDocument();
        return byteArrayOutputStream.toString("UTF-8");
    }

    public void a(String str) throws XmlPullParserException, IOException {
        XmlPullParser a = p.a(str.getBytes("UTF-8"));
        for (int eventType = a.getEventType(); 1 != eventType; eventType = a.next()) {
            String name = a.getName();
            switch (eventType) {
                case 2:
                    if (HiAnalyticsConstant.BI_KEY_RESUST.equals(name)) {
                        this.b = g.a(a.getAttributeValue(null, "resultCode"));
                    }
                    if (this.b != 0) {
                        if (!"errorCode".equals(name)) {
                            if (!"errorDesc".equals(name)) {
                                break;
                            }
                            this.d = a.nextText();
                            break;
                        }
                        this.c = g.a(a.nextText());
                        break;
                    } else if (!"delTGCCount".equals(name)) {
                        break;
                    } else {
                        this.l = a.nextText();
                        break;
                    }
                default:
                    break;
            }
        }
    }

    public String b() {
        return this.m;
    }

    public void a(Context context, a aVar, String str, com.huawei.hwid.core.helper.handler.a aVar2) {
        com.huawei.hwid.core.b.a.e.a(context, aVar, str, a(context, aVar, aVar2));
    }

    public Bundle c() {
        Bundle c = super.c();
        c.putString("delCount", this.l);
        return c;
    }

    public String c(Context context) {
        return b.f(context);
    }
}
